#include <memory>
#include "EpollServer.hpp"

Response Calculator(Request req)
{
    Response resp;
    switch (req._op)
    {
    case '+':
        resp._result = req._x + req._y;
        break;
    case '-':
        resp._result = req._x - req._y;

        break;
    case '*':
        resp._result = req._x * req._y;

        break;
    case '/':
        if(req._y == 0)
            resp._code = 1;
        else
            resp._result = req._x / req._y;
        break;
    case '%':
        if(req._y == 0)
            resp._code = 0;
        else
            resp._result = req._x % req._y;
        break;
    default:
        resp._code = 2;
    }
    return resp;
}


int main()
{
    std::unique_ptr<EpollServer> svr(new EpollServer(Calculator));   
    svr->InitServer();
    svr->Dispatcher();
    return 0;
}